import com.google.common.eventbus.EventBus;

import java.util.Objects;

/**
 * Created on 2020/3/24
 * Title: 咕泡学院学生
 * Description: 咕泡学院学生，观察者模式中，属于Subject
 * Copyright: Copyright(c) 2020
 * Company:
 *
 * @author yifeng
 */
public class Gper {

    /**
     * guava的消息总线
     */
    private EventBus eventBus;
    /**
     * 提问者名字
     */
    private String name;

    public Gper(EventBus eventBus, String name) {
        Objects.requireNonNull(eventBus);
        Objects.requireNonNull(name);
        this.eventBus = eventBus;
        this.name = name;
    }

    public void submitQuestion(Question question) {
        Objects.requireNonNull(question);
        System.out.println(name + "提出问题, 内容: " + question.getContent());
        question.setQuizzerName(name);
        eventBus.post(question);
    }

}
